import React, { Component } from "react";
import { Redirect,Route } from "react-router-dom";
import { Layout } from "antd";
import memoryUtils from "../../utils/memoryUtils";
import LeftNav from '../../components/left-nav'
import Header from '../../components/header'


//子路由
import Category from "../category/category"
import Bar from "../charts/bar"
import Line from "../charts/line"
import Pie from "../charts/pie"
import Home from "../home/home"
import Product from "../product/product"
import Role from "../role/role"
import User from "../user/user"

const { Footer, Sider, Content } = Layout;
class admin extends Component {
  render() {
    const user = memoryUtils.user;
    if (!user || !user._id) {
      //如果内存中没有存储user  当前没有登录
      return <Redirect to="/login" />;
    }
    return (
     
			<Layout style={ {minHeight:"100%"}}>
			<Sider>
				<LeftNav/>
		  </Sider>
          <Layout>
            <Header>Header</Header>
          	<Content style={{margin:'20px',background:'#fff'}}>
            <Route path='/home' component={ Home } />
            <Route path='/category' component={ Category } />
            <Route path='/product' component={ Product } />
            <Route path='/role' component={Role} />
            <Route path='/user' component={User} />
            <Route path='/charts/bar' component={ Bar } />
            <Route path='/charts/line' component={Line} />
            <Route path='/charts/pie' component={ Pie } />
            <Redirect to='/home'/>
        </Content>
				<Footer style={ {textAlign:'center',color:'#ccc'}}>推荐使用谷歌浏览器，可以获得更佳页面效果</Footer>
          </Layout>
        </Layout>
  
    );
  }
}

export default admin;
